package leecode;

import org.junit.Test;

import java.util.Arrays;
import java.util.PriorityQueue;

public class Question452 {

    public int findMinArrowShots(int[][] points) {
        if(points.length == 0) return 0;
        Arrays.sort(points, (p1, p2) -> p1[1] < p2[1] ? -1 : 1);
        int res = 1;
        int pre = points[0][1];
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > pre) {
                res++;
                pre = points[i][1];
            }
        }
        return res;
    }

    public double myPow(double x, int n) {
        int res = 1;
        double mul = n > 0 ? x : 1 / x;
        return mul(res, mul, 0, Math.abs(n) - 1);
    }

    public double mul(double res, double mul, int l, int r) {

        if (l == r) {
            return mul;
        }
        int mid = (l + r) / 2;
        double left = mul(res, mul, l, mid);
        double right = mul(res, mul, mid + 1, r);
        return left * right;
    }



    @Test
    public void main(){
//        int[][] arr = {{3,9},{7,12},{3,8},{6,8},{7,8},{2,9},{0,9},{3,9},{0,6},{2,8}};
//        int[][] arr = {{3,9},{3,8},{6,8},{2,9},{0,9},{3,9},{0,6},{2,8}};
//        Arrays.sort(arr, (a, b) -> a[1] - b[1]);
//        System.out.println(ArrayUtil.toString(arr));
//        System.out.println(findMinArrowShots(arr));
        System.out.println(myPow(2.10000, 3));
    }
}
